package com.franklin.java.entity;

import java.util.concurrent.TimeUnit;

/**
 * 消耗时间
 * @author Franklin
 * @since 2021/9/26 11:37
 */
public class CostTime {

    private Long start;
    private Long end;
    private TimeUnit timeUnit;

    public final static CostTime ZERO = new CostTime(0L,0L,TimeUnit.MILLISECONDS);
    public final static CostTime FIRST = new CostTime(0L,25L,TimeUnit.MILLISECONDS);

    public CostTime(Long start, Long end, TimeUnit timeUnit) {
        this.start = start;
        this.end = end;
        this.timeUnit = timeUnit;
    }

    public Long getDuration(){
        return this.end - this.start;
    }

    public Long getStart() {
        return start;
    }

    public Long getEnd() {
        return end;
    }

    @Override
    public String toString() {
        return "CostTime : " + this.getDuration() + " " + timeUnit;
    }
}
